<template>
  <div>
    <!-- banner图 -->
    <div class="swipe-box">
      <van-swipe :autoplay="3000">
        <van-swipe-item v-for="(image, index) in img" :key="index">
          <div class="img-box">
            <img style="width:100%" :src="image.banner_path">
          </div>
        </van-swipe-item>
      </van-swipe>
    </div>
  </div>
</template>

<script>
import { getBanners } from "@/api/home";

export default {
  name: "BannerItem",
  data() {
    return {
      images: [],
      img: [
        {
          id: 1,
          url: "http://www.baidu.com",
          banner_path: "https://gw.alicdn.com/tfs/TB1teJsOkPoK1RjSZKbXXX1IXXa-750-410.png"
        }
      ]
    };
  },
  methods: {
    async Banner() {
      let company_id = localStorage.getItem("companyId");
      let par = {
        company_id: company_id
      };
      let query = Object.assign({}, par);
      let res = await getBanners(query);
      let result = res.data;
      if (result.status == 100) {
        this.images = result.data.rows;
      }
    }
  },
  created() {
    this.Banner();
  },
  mounted() {}
};
</script>

<style lang="scss" scoped>
.swipe-box {
  .img-box {
    width: 100%;
    //   height: 300px;
    overflow: hidden;
  }
}
</style>
